<template>
	<view>
		<view class="" style="padding-top: 20rpx;">
			<view class="xr flex_r_between palr_20">
				<view class="ti">姓名</view>
				<view>
					<input type="text" v-model="realname" placeholder="请输入姓名" />
				</view>
			</view>
			<view class="xr flex_r_between palr_20">
				<view  class="ti">身份证号</view>
				<view>
					<input type="text" v-model="id_card_no" placeholder="请输入身份证号" />
				</view>
			</view>
			<view class="palr_20">
				<view class="tip">
					请上传身份证照片
				</view>
				<view class="flex_r_between">
					<image @click="uploadIDcard(1)" style="width: 320rpx;height: 240rpx;" :src="id_card_image1!=''?'http://'+id_card_image1:'../../static/spokesmanImg/icon/bg_id_people@2x.png'||'../../static/微信图片_20201124091755.png'" mode=""></image>
					<image @click="uploadIDcard(2)" style="width: 320rpx;height: 240rpx;" :src="id_card_image2!=''?'http://'+id_card_image2:'../../static/spokesmanImg/icon/bg_id_badge@2x.png'||'../../static/微信图片_20201124091755.png'" mode=""></image>
				</view>
			</view>
			<view class="palr_20 flex_r_start ers">
				<image v-show="isgx" @click="isgx=!isgx" style="width: 32rpx;height: 32rpx;" src="../../static/spokesmanImg/icon/selected_on.png" mode=""></image>
				<image v-show="!isgx" @click="isgx=!isgx" style="width: 32rpx;height: 32rpx;" src="../../static/spokesmanImg/icon/selected_on1.png" mode=""></image>
				<view class="xy">
					我已同意并同意<span style="color: #1C597F;"  @click="$linkTo(`./web_view/web_view?url=${'http://dev.feelmao.com/wap/user/agreement_view'}`)">《肥猫用户协议》</span>
				</view>
			</view>
			<view class="tijiao" @click="submit">
				提交
			</view>
			<view class="hg">
				信息仅用于身份认证，我们将严格保护您的数据和隐私安全
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token:'',
				realname:'',
				id_card_no:'',
				id_card_image1:'',
				id_card_image2:'',
				isgx:true,
			};
		},
		onShow() {
			this.$request('/app/upload/getUploadConfig','post',{
				qwe:1
			}).then(res=>{
				this.token=res.content.token
			})
		},
		methods:{
			uploadIDcard(i){
				uni.chooseImage({
				    count: 6, //默认9
				    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
				    sourceType: ['album','camera'], //从相册选择
				    success: (res)=>{
						this.$UploadImg(res.tempFilePaths[0],this.token).then(res1=>{
							console.log(res1.imageURL)
							if(i===1){
								this.id_card_image1=res1.imageURL
							}else if(i===2){
								this.id_card_image2=res1.imageURL
							}
						})
						
						
				    }
				});
			},
			submit(){
				if(!this.isgx){
					uni.showToast({
						title:'请勾选用户协议',
						duration:2000,
						icon:'none'
					})
					return
				}
				this.$request('/app/user/authUserRealInfo','post',{
					access_token:uni.getStorageSync('access_token').replace(/^\"|\"$/g,''),
					realname:this.realname,
					id_card_no:this.id_card_no,
					id_card_image1:this.id_card_image1,// String, 正面
					id_card_image2:this.id_card_image2//: String 反面
				}).then(res=>{
					if(res.errcode===0){
						this.$navigateBack()
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("@/static/css/flex.css");
	.ers{
		margin: 82rpx auto 30rpx;
	}
	.hg{
		font-size: 22rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #AAAAAA;
		text-align: center;
		margin-top: 30rpx;
	}
	.tijiao{
		width: 660rpx;
		height: 80rpx;
		background: #DB1B22;
		border-radius: 40rpx;
		margin: auto;
		font-size: 34rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
	}
	.xy{
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #AAAAAA;
		margin-left: 15rpx;
	}
	.tip{
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #AAAAAA;
		margin: 20rpx 0;
	}
	.xr{
		height: 100rpx;
		border-bottom: 1px solid #F3F3F3;
		.ti{
			font-size: 30rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #323232;

		}
		input{
			text-align: right;
			
font-size: 28rpx;
		}
	}
	.palr_20{
		padding: 0 40rpx;
		box-sizing: border-box;
	}
</style>
